package cn.wolfcode.crm.web.controller;

<<<<<<< HEAD

import cn.wolfcode.crm.domain.SafetyMechanism;
=======
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
import cn.wolfcode.crm.domain.SafetyMechanism;
import cn.wolfcode.crm.page.PageResult;
import cn.wolfcode.crm.query.SafetyMechanismQueryObject;
import cn.wolfcode.crm.service.ISafetyMechanismService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PermissionName;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
<<<<<<< HEAD
import java.util.List;
=======
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493

@Controller
@RequestMapping("safetymechanism")
public class SafetyMechanismController {

    @Autowired
<<<<<<< HEAD
    private ISafetyMechanismService safetyMechanismService;

    @RequestMapping("listAll")
    @ResponseBody
    public List<SafetyMechanism> listAll(){

        return safetyMechanismService.listAll();

    }
=======
    private ISafetyMechanismService safetymechanismService;
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493

    @RequestMapping("")
    @RequiresPermissions("safetymechanism:index")
    @PermissionName("机构列表")
    public String index() {
        //只负责跳转到safetymechanism.jsp页面即可
        return "safetymechanism";
    }
    @RequestMapping("list")
    @RequiresPermissions("safetymechanism:list")
    @PermissionName("机构数据")
    @ResponseBody
    public PageResult list(SafetyMechanismQueryObject qo) {
<<<<<<< HEAD
        PageResult result = safetyMechanismService.query(qo);
=======
        PageResult result = safetymechanismService.query(qo);
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
        return result;
    }

    @RequestMapping("save")
    @RequiresPermissions("safetymechanism:save")
    @PermissionName("机构保存")
    @ResponseBody
    public JsonResult save(SafetyMechanism safetymechanism) {
        JsonResult result = new JsonResult();
        try{
<<<<<<< HEAD
            safetyMechanismService.insert(safetymechanism);
=======
         safetymechanismService.insert(safetymechanism);
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
         result.setMessage("保存成功");
        }catch (Exception e){
            e.printStackTrace();
            result.mark("保存失败");
        }

        return result;
    }
    @RequestMapping("edit")
    @RequiresPermissions("safetymechanism:edit")
    @PermissionName("机构编辑")
    @ResponseBody
    public JsonResult edit(SafetyMechanism safetymechanism) {
        JsonResult result = new JsonResult();
        try{
<<<<<<< HEAD
            safetyMechanismService.updateByPrimaryKey(safetymechanism);
=======
         safetymechanismService.updateByPrimaryKey(safetymechanism);
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
        result.setMessage("编辑成功");
        }catch (Exception e){
            e.printStackTrace();
            result.mark("编辑失败");
        }
        return result;
    }
    @RequestMapping("changeState")
    @RequiresPermissions("safetymechanism:changeState")
    @PermissionName("机构解散")
    @ResponseBody
    public JsonResult quit(Long id) {
        JsonResult result = new JsonResult();
        try{
<<<<<<< HEAD
            safetyMechanismService.updateState(id);
=======
         safetymechanismService.updateState(id);
>>>>>>> 524224bf820c6d6da01f752551ee21b728709493
        result.setMessage("解散成功");
        }catch (Exception e){
            e.printStackTrace();
            result.mark("解散失败");
        }
        return result;
    }
}